//
//  AppDelegate.m
//  礼物
//
//  Created by dllo on 15/11/4.
//  Copyright © 2015年 liangsicheng. All rights reserved.
//

#import "AppDelegate.h"
#import "UMSocial.h"
@interface AppDelegate ()<UITabBarControllerDelegate>

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    self.window=[[UIWindow alloc]init];
    [self.window makeKeyAndVisible];
    
    UINavigationController *homePageNaVC=[[UINavigationController alloc]initWithRootViewController:[[HomePageViewController alloc]init]];
    UINavigationController *recommendNaVc=[[UINavigationController alloc]initWithRootViewController:[[RecommendViewController alloc]init]];
   UINavigationController *audioVisualNaVc=[[UINavigationController alloc]initWithRootViewController:[[VisualViewController alloc]init]];
    UINavigationController *discoveryNaVc=[[UINavigationController alloc]initWithRootViewController:[[DiscoveryViewController alloc]init]];
    UINavigationController *userNaVc=[[UINavigationController alloc]initWithRootViewController:[[UserViewController alloc]init]];
    homePageNaVC.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"首页" image:[UIImage imageNamed:@"1"] tag:10000];
    discoveryNaVc.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"发现" image:[UIImage imageNamed:@"4"] tag:10002];
    recommendNaVc.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"推荐" image:[UIImage imageNamed:@"2"] tag:10003];
    audioVisualNaVc.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"视频" image:[UIImage imageNamed:@"5"] tag:10004];
    userNaVc.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"我的" image:[UIImage imageNamed:@"3"] tag:10004];
    UITabBarController *tabBarC=[[UITabBarController alloc]init];
    tabBarC.viewControllers=[NSArray arrayWithObjects:homePageNaVC,recommendNaVc,audioVisualNaVc,discoveryNaVc,userNaVc, nil];
    tabBarC.tabBar.barTintColor=[UIColor whiteColor];
    tabBarC.tabBar.tintColor=[UIColor colorWithRed:38.0/255.0 green:215.0/255.0 blue:164.0/255.0 alpha:0.680];//设置选中颜色
    tabBarC.tabBar.translucent=NO;//是否取消半透明效果，no是没有半透明效果
    //    tabBarC.tabBar.backgroundImage=[UIImage imageNamed:@"1.jpg"];
    //协议代理
    tabBarC.delegate=self;
    [UMSocialData setAppKey:@"507fcab25270157b37000010"];
    self.window.rootViewController=tabBarC;

    [[DataBaseHandle shareDataBaseHandle]openDB1];
    [[DataBaseHandle shareDataBaseHandle]createAllTable];
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
